//
// Author    : Pablo Bosch 
// Contact   : pboschvivancos@epo.org
// Created   : 08/05/2005
// Last Modif: 08/05/2005
//


var MOD_DOSSIER = {
  DUMMYDOS:  "SAxxxxx",
  DUMMYDATE: "dd/mm/yyyy",
  DOSMAXCOLS: 5
};


function dossier_type(fname) {
    var mclass="";
    switch(fname.substr(0,2)) {
	case "EP":
     	 return "EPDOS";
        break;
        case "FA":
	case "FR":	
         return "FADOS";
        default:
	if(is_numeric(fname.charAt(0))) {
	   return "EPDOS";
        }else {
           return "SADOS";
        }
    }   
}

// try to find best default value for next claim set phase
function finddefaultphase(str) {
  var preffase="";
  if(!str) {
    if(GetClaimSetsLength()>0) {
      SelectClaimSet(GetClaimSetsLength());
      str=GetClaimSetAppNum();
    } else {
      str=GetDossierNumber();
    }
   }         
   switch(str.substring(0,2)) {
      case "FR":
      case "FA":
	preffase="FR";
        break;      
      case "SA":
  	preffase="PCT";
      break;
      case "EP":
        preffase="EP";
      break;
      default:
      if(is_numeric(str.charAt(0))) {
         preffase="EP";   // 02352525.7 EP style number 
      } else {
	 preffase="PCT";   // US1238238, DE2372837 etc...
      }
  } 
  return preffase;
}


function select_dossier(dname) {
  html_reset();
  var vers=GetPrefVersion(dname);
  //selview=GetPrefView(dname);
  seldoc=GetPrefDoc(dname);
  if(vers && GetClaimSetsLength()>=1) { 
    if(SelectClaimSet(vers)) {
      var sect=GetPrefSection(dname);
      if(sect) {
	try {
	  //alert("Goto "+sect);
	  eval(sect);
	} catch(er) {
	  alert("Unknown/Obsolete method "+sect);
	  edit_claimsetview(vers);
	}
      } else {
	edit_claimsetview(vers);
      }
    } else {
      alert("Cannot select vers "+vers);
      show_editdossier();
    }
  } else {
    SelectClaimSet(1);
    show_editdossier();
  }
}

function LoadLastDossier() {
  var dos_iter = new lastdossiers_iterator();
  if(!dos_iter.end()){
    var dname=dos_iter.getDossNum();
    if(LoadDossier(dname)) {
      select_dossier(dname);
    }
  }
}

// render recent files  
MOD_DOSSIER.recent_files=function() {
  var dos_iter = new lastdossiers_iterator();
  var html="";
  if(dos_iter.end()) {
    return "";
  }
  html+=" <select id=recentsel valign=top>";
  while(!dos_iter.end()) {
    html+="<option> "+dos_iter.getDossNum()+"</option>";
    dos_iter.next();	
  } 
  html+="</select> ";
  return html;
}

//
// List directory contents
//

MOD_DOSSIER.DOSFILES=[];
function list_dossiers() {
  MOD_DOSSIER.DOSFILES=dos_dir(GetDossiersDir(),".xml");
  return MOD_DOSSIER.DOSFILES.length>0;
}

MOD_DOSSIER.onchangedfolder=function(dfolder) {
  deletedossiercache();
  SetDossiersDir(dfolder);
  show_opendossier(); 
}
  
MOD_DOSSIER.doss_iter;
MOD_DOSSIER.dossiersortby= function(field) {
  MOD_DOSSIER.doss_iter.sort(field);
  show_opendossier();
}


MOD_DOSSIER.do_importdesc=function(){
  do_importdesc();
  var minidesc=GetDossierDescription().substring(1,120)+" ...";
  html_flexarea_settxt("minidesc",minidesc); 
}   

//
//  Open 
// 

function show_opendossier() {
  var html="<H3><BUTTON>"+html_img(section_img)+" </BUTTON> Open Dossier</h3>";
 
  html+="<table ><tr valign=center><th align=left width=200>";
  html+="<button onclick='var obj=getElementById(\"recentsel\");"
  html+=" MOD_DOSSIER.onopendossier(obj.options[obj.selectedIndex].text);'>";
  html+=html_img(openfile_img);
  html+="</button>";
  html+=" Last Visited </TH>";

  html+="<TH  width=270 align=left>"+MOD_DOSSIER.recent_files()+"</TH>";
  html+="<TH align=left width=250><BUTTON onclick='MOD_DOSSIER.onfinddossier(document.getElementById(\"fftxt\").value);'>"+html_img(find_img)+"</BUTTON>";
  html+=" Find <input type=text id=fftxt size=20 onchange='MOD_DOSSIER.onfinddossier(this.value);'";
  html+=" id='findoss' value='"+MOD_DOSSIER.findossier+"'>";
  html+="</TH><TH align=left width=300>"+find_dossier();
  html+="</th></tr>";
  html+="<tr><td valign=center>&nbsp;<BR>&nbsp;</td></tr>";
  html+="<tr><th colspan=4 align=left ><BUTTON TYPE=Button onclick='MOD_DOSSIER.onchangedfolder(document.getElementById(\"dfname\").value);'>"+
    html_img(chcd_img)+" </BUTTON>";
  html+=" Dossiers in folder: <input type=text size=84 id='dfname' value='"+GetDossiersDir()+"'";
  html+=" onChange='MOD_DOSSIER.onchangedfolder(this.value);'></th><td></td></tr>";
  html+="<TR><TD colspan=4>";
  
  html+="<TABLE border=1>";
  html+="<TR>";
  html+="<TH><input type=button value='#' class='FULLW' onclick='MOD_DOSSIER.dossiersortby(\"on\")'></TH>";
  html+="<TH><input type=button value='Dossier' class='FULLW' onclick='MOD_DOSSIER.dossiersortby(\"dn\")'></TH>";
  html+="<TH><input type=button value='Priority' class='FULLW' onclick='MOD_DOSSIER.dossiersortby(\"pri\")'></TH>";
  html+="<TH><input type=button value='Last Action' class='FULLW' onclick='MOD_DOSSIER.dossiersortby(\"last\")'></TH>";
  html+="<TH><input type=button value='Title' class='FULLW' onclick='MOD_DOSSIER.dossiersortby(\"title\")'></TH>";
  html+="</TR>";
  MOD_DOSSIER.doss_iter = new dossier_cacheiterator(GetDossiersDir()); 
  var altlines=0;
  var classline="bigpopup1";
  while(!MOD_DOSSIER.doss_iter.end()) {
    if(altlines) {
      classline="bigpopup1";
      altlines=0;
    } else {
      classline="bigpopup2";
      altlines=1;
    }
    if(MOD_DOSSIER.doss_iter.getEndDate()) { 
      classline="DEAD";
    }
    html+="<TR>";
 
    html+="<TD align=right class='"+classline+"'>"+MOD_DOSSIER.doss_iter.getOrdNum()+"</TD>";
    html+="<TD class='"+dossier_type(MOD_DOSSIER.doss_iter.getNumber())+"'><A  ";
    html+="  href='#' onclick='MOD_DOSSIER.onopendossier(\""+MOD_DOSSIER.doss_iter.getNumber()+"\");'>"+MOD_DOSSIER.doss_iter.getNumber()+"</A></TD>";
    
    //html+="<TD class='"+classline+" '><input type=button value='"+doss_iter.getNumber()+"' class='FULL ";
    //html+=dossier_type(doss_iter.getNumber())+"' onclick='onopendossier(this.value);' ></TD>";
    html+="<TD class='"+classline+"' >"+MOD_DOSSIER.doss_iter.getPri()+"</TD>";
    html+="<TD class='"+classline+"'>";
    if(MOD_DOSSIER.doss_iter.getEndDate()) {
      html+=html_whatis(MOD_DOSSIER.doss_iter.getLastAction() || "END",MOD_DOSSIER.doss_iter.getEndDate());
    } else {
      html+=MOD_DOSSIER.doss_iter.getLastAction();
    }
    html+="</TD>";
    html+="<TD class='"+classline+"' style='height:25px;'>"+MOD_DOSSIER.doss_iter.getTitle()+"</TD>";
    html+="</TR>";
    MOD_DOSSIER.doss_iter.next();
  }
  html+="</TABLE></TD></TR></TABLE>";

  html_display(html);
  
}



// find dossiers 

MOD_DOSSIER.findossier="";
MOD_DOSSIER.dossiersfound= new Array();

MOD_DOSSIER.onfinddossier=function(txt) {
  if(txt) {
    MOD_DOSSIER.findossier=trim(txt);
  }	
  if(MOD_DOSSIER.findossier) {
    MOD_DOSSIER.dossiersfound= new Array();
    
    var dos_iter = new dossier_iterator();
    var progbar = new html_progbar("Searching "+dos_iter.length()+" files",dos_iter.length());
    
    while(!dos_iter.end()) {
      progbar.message(dos_iter.getNumber());
      if(dossier_search(dos_iter.getNumber(),MOD_DOSSIER.findossier)) {
	MOD_DOSSIER.dossiersfound.push(dos_iter.getNumber());
      }	
      dos_iter.next();
      progbar.advance();
    }
    
    progbar.close();      
    show_opendossier();
  }
}


function find_dossier() {
  var html="";
  if(MOD_DOSSIER.findossier && MOD_DOSSIER.dossiersfound.length) {
    html+="<select id=foundsel>";
    for(f in MOD_DOSSIER.dossiersfound) {
      html+="<option> "+MOD_DOSSIER.dossiersfound[f]+"</option>";
    } 
    html+="</select> ";
    html+="<button onclick='var obj=getElementById(\"foundsel\");"
      html+=" MOD_DOSSIER.onopendossier(obj.options[obj.selectedIndex].text);'>";
    html+=html_img(openfile_img);
    html+="</button>";
    
  } else if(MOD_DOSSIER.findossier) {
    return "none found";
  }

  return html;
}

//
// New 
//


MOD_DOSSIER.create_dossier = function() {
  html_reset();
  var dname=document.getElementById("dosname");
  var dlang=document.getElementById("doslang");
  var dpri=document.getElementById("dospri");
  var ordnum=document.getElementById("dosord");
  if(parseInt(ordnum.value)>=GetPrefsOrdNum()) {
    SetPrefsOrdNum(parseInt(ordnum.value)+1);
  }
  //alert("Create Dossier "+dname.value);
  if(LoadDossier(dname.value,"silent")!=0) {
     alert("Dossier "+dname.value+" already exists.\nOpening...");
     show_editdossier();
     return;
  }
  CLAIMSET=null;
  DOCS=null;
  var ddate=dpri.value;
  if(ddate==MOD_DOSSIER.DUMMYDATE) {
    ddate="";
  }
  if(dname.value!= MOD_DOSSIER.DUMMYDOS) {
    CreateDossier(dname.value,html_selected_iter("doslang"),ddate,ordnum.value);
    PrefInsertDossier(dname.value);    
    show_editdossier();
  }
}


function show_newdossier() {
    var html="<H3><BUTTON TYPE=Button>"+html_img(section_img)+" </BUTTON> New Dossier</h3>";

    html+="<TABLE border=1>";
    html+="<TR><TH align=left width=200> Dossier Number   </TH>";
    html+="<TD><input type=text class='DOSNUM' name=dosname onChange='this.value=NormalizeDossierNumber(this.value);' value='"+MOD_DOSSIER.DUMMYDOS+"'></TD></TR>";
    html+="<TR><TH align=left> Language </TH><TD>"+html_selection_iter("doslang",new lang_iterator())+"</TD></TR>";    
    html+="<TR><TH align=left> Priority </TH><TD><input type=text class='DATE' name=dospri value='"+MOD_DOSSIER.DUMMYDATE+
      "' onchange='MOD_DOSSIER.onchangedate(this)'></TD></TR>";
    html+="<TR><TH align=left> Ord. number </TH><TD><input type=text size=10 name=dosord value='"+GetPrefsOrdNum()+"'></TD></TR>";
    html+="<TR><TD colspan=2><BUTTON onclick='MOD_DOSSIER.create_dossier();' class='bcreate' ACCESSKEY='C'><u>C</u>reate</button>";   
    html+="</TD></TR></TABLE>"; 
    html_display(html);
}

//
// Save 
//

function save_dossier() {
  if(!DOSSIER) {
    alert("Create or Load a dossier first !");
    return;
  }
 
  var dossier=GetDossierNumber();
  alert("Saving in dossiers/"+dossier+".xml");
  SaveDossier(dossier);
  return false;
}

//
// Callbacks  
//

MOD_DOSSIER.onchangedate = function(obj) {
   obj.value=normalizeDate(trim(obj.value));
}

MOD_DOSSIER.onopendossier=function(dname) {
  //alert("Open dossier "+dname);
  PrefInsertDossier(dname);
  if(LoadDossier(dname)) {
     select_dossier(dname);
   }
}

MOD_DOSSIER.onchangedoslang=function() {
  var lang=html_selected_iter("doslang");
  SetDossierLang(lang);
}

MOD_DOSSIER.changedosordnum=function(obj) {
  SetDossierOrdNum(obj.value);
  obj.value=GetDossierOrdNum();
}	 

MOD_DOSSIER.changedospri=function(obj) {
  obj.value=normalizeDate(obj.value);
  SetDossierPri(obj.value);
}


MOD_DOSSIER.updatermks=function(ver,txt) {
  SetClaimSetRmks(document.getElementById("rmks"+ver).value,ver);
}

MOD_DOSSIER.rmkshow=function(ver) {
  var  obj=document.getElementById("rmks"+ver);
  var vobj=document.getElementById("vrmks"+ver);
  var bobj=document.getElementById("rshow"+ver);
  var sobj=document.getElementById("spanrmks"+ver);
  
  if(MOD_DOSSIER.showrmks[ver]==1) {
    vobj.style.display='none';
    if(obj.value && trim(obj.value)!="") {
      html_img_replace("rshow"+ver,editrmks_img);
    } else {
      html_img_replace("rshow"+ver,addrmks_img);
    }
    sobj.rowspan=1;
    MOD_DOSSIER.showrmks[ver]=0;
  } else {
    vobj.style.display='block';
    obj.rows=countLines(obj.value,obj.cols);
    html_img_replace("rshow"+ver,hidermks_img);
    sobj.rowspan=2;
    MOD_DOSSIER.showrmks[ver]=1;
  }
  //this.element.style.visibility = 'visible';
}

MOD_DOSSIER.showrmks=new Array();

function finddefaultappnum() {
   if(GetClaimSetsLength()>0) {
      SelectClaimSet(GetClaimSetsLength());
      return GetClaimSetAppNum();
    } else {
      return GetDossierNumber();
    }            
}


// Edit claimset entry
MOD_DOSSIER.onchangeappnum=function(obj) {
  obj.value=ClaimSetAppNumNormalize(obj.value);
  html_doselect("clsphase",PHASES,finddefaultphase(obj.value));
}

MOD_DOSSIER.onchangeedappnum=function(obj) {
  obj.value=ClaimSetAppNumNormalize(obj.value);
}

MOD_DOSSIER.onchangeeddate=function(obj) {
  obj.value=normalizeDate(obj.value);
}


MOD_DOSSIER.editvers=0;
MOD_DOSSIER.edit_dossiercallback=show_editdossier;

MOD_DOSSIER.exitedit_dossier=function(vers) {
  MOD_DOSSIER.editvers=0;
  MOD_DOSSIER.edit_dossiercallback();
  //edit_dossier();// Resize claims 
}

MOD_DOSSIER.updedit_dossier=function(vers) {
    SelectClaimSet(vers);
    SetClaimSetLabel(document.getElementById("edlab").value);
    SetClaimSetAppNum(document.getElementById("edclsapp").value);
    SetClaimSetDate(document.getElementById("edclsdate").value);
    SetClaimSetPhase(html_selected("edclsphase",PHASES));
    SetClaimSetLength(document.getElementById("edclsnum").value);
    MOD_DOSSIER.editvers=0;
    MOD_DOSSIER.edit_dossiercallback();
    //edit_dossier();// Resize claims 
}

MOD_DOSSIER.open_desc=function() {
  var ppp=null;
  //register_inspect(); return;
	
  ppp=window.open("","Description","height=800,width=645,scrollbars=no,resizable=yes,menubar=yes");
  if(ppp) {
    ppp.document.write("<html><head><title>"+GetDossierNumber()+"</title><link rel='stylesheet' href='claimtool.css'></head><body>");
    ppp.document.write("<TABLE><TR><TH>Description</TH></TR><TR><TD><TEXTAREA class=commarea ROWS=40 COLS=60>");
    ppp.document.write(GetDossierDescription());
    ppp.document.write("</TEXTAREA></TD></TR></TABLE></body></html>");
    ppp.document.close();
  } else {
    alert("Cannot open popup");
  }
}


MOD_DOSSIER.onedit_dossier=function(editvers) {
  MOD_DOSSIER.editvers=editvers;
  MOD_DOSSIER.edit_dossiercallback();
} 


MOD_DOSSIER._editclaimsets=function(callback) {
  MOD_DOSSIER.edit_dossiercallback=callback;
  
  var lastdate="",lastapp="",lastphase;  
  var html="",trhtml="";

  html+="<TABLE border=1 width=100%>";
  html+="<TR><TH></TH><TH width=20> # </TH><TH>Label</TH><TH>Application<br> Number</TH><TH>Filing<br> date</TH>";
  html+="<TH>Phase</TH><TH> Number of<br> claims</TH><TH></TH><TH></TH></TR>"; 
  
  for(var cls_iter= new claimsets_iterator();!cls_iter.end(); cls_iter.next()) {
    lastdate=cls_iter.getDate();
    lastphase=cls_iter.getPhase();
    var rhtml="";
    var rmks=cls_iter.getRmks();
    var rmkclass=rmks ? "RMKS" : "NORMKS";
    var vers=cls_iter.getValue();
    rhtml+="<TR>";
    rhtml+="<TD align=center ><button onClick='open_claimset("+vers+");'>"+html_img(open_img)+"</button></TD>";	
    rhtml+="<TH align=center  ID='spanrmks"+vers+"' height=100%><button onClick='open_claimset("+vers+");'>"
      +vers+"</button></TH>";
    if(vers == MOD_DOSSIER.editvers) {
      rhtml+="<TD align=center><input type=text name=edlab size=4  value='"+cls_iter.getLabel();
      rhtml+="' ></TD>";
      rhtml+="<TD align=center><input type=text name=edclsapp   class='APPNUM' value='"+cls_iter.getAppNum();
      rhtml+="' onchange='MOD_DOSSIER.onchangeedappnum(this);'></TD>";
      rhtml+="<TD align=center><input type=text name=edclsdate  class='DATE' value='"+cls_iter.getDate();
      rhtml+="' onchange='MOD_DOSSIER.onchangeeddate(this)'></TD>";
      rhtml+="<TD align=center>"+html_selection("edclsphase",PHASES,cls_iter.getPhase())+"</TD>";
      rhtml+="<TD align=center><input type=text name=edclsnum size=4  value='"+cls_iter.getLength();
      rhtml+="' ></TD>";
    } else {
      rhtml+="<TD align=center>"+ cls_iter.getLabel()+"</TD>";
      rhtml+="<TD align=center>"+ cls_iter.getAppNum()+"</TD>";
      rhtml+="<TD align=center>"+ cls_iter.getDate()+"</TD>";
      rhtml+="<TD align=center>"+ cls_iter.getPhase()+"</TD>";
      rhtml+="<TD align=center>"+ cls_iter.getLength()+"</TD>";
    }
    if(!MOD_DOSSIER.editvers) {
      rhtml+="<TD align=center align=right>";
      rhtml+="<button onClick='MOD_DOSSIER.rmkshow("+vers+");'  >"; //class='"+rmkclass+"'>"
      if(MOD_DOSSIER.showrmks[vers]==1) { 
	rhtml+=html_img(hidermks_img,"rshow"+vers); //       
      } else {
	if(rmks) {
	  rhtml+=html_img(editrmks_img ,"rshow"+vers); // rmks not empty 
	} else {           
	  rhtml+=html_img(addrmks_img,"rshow"+vers); //        
	}
      } 
      rhtml+="</BUTTON></TD>"; 
      rhtml+="<TD align=center ><button class='bedit'";
      rhtml+=" onClick='MOD_DOSSIER.onedit_dossier("+vers+");'>"+html_img(edit_img)+"</button></TD>";	
    } else {
      rhtml+="<TD align=center ><button onClick='MOD_DOSSIER.updedit_dossier("+vers+");'>"+html_img(ok_img);
      rhtml+="</TD><TD><button onClick='MOD_DOSSIER.exitedit_dossier("+vers+");'>"+html_img(cancel_img)+"</TD>";
    }
    rhtml+="</TR><TR ID='vrmks"+vers+"' class=HIDEME ><TD></TD><TD></TD><TD  colspan=6>";
    rhtml+=html_flexarea(rmks,"MOD_DOSSIER.updatermks("+vers+")","ID='rmks"+vers+"'",60);
    rhtml+="</TD></TR>";
    trhtml+=rhtml;
  } 
  html+=trhtml;

  // retreive default values
  if(MOD_DOSSIER.defdata) {
    lastdate=MOD_DOSSIER.defdata.date;
    lastapp =MOD_DOSSIER.defdata.num;
    lastphase=MOD_DOSSIER.defdata.phase;
  } else {
    lastapp =finddefaultappnum();
    if(GetDossierPri()) {
      var ldate=str2Date(GetDossierPri());
      ldate.setDate(ldate.getDate()+365);
      lastdate=Date2str(ldate); // one year later...
    } 
    lastphase=finddefaultphase();  
  }
  
  html+="<TR>";
  html+="<TD align=center>";
  html+="<BUTTON onclick='add_claimset(clsdate.value,html_selected(\"clsphase\",PHASES),clsapp.value,clsnum.value,clslab.value);'";
  html+=" id=addcsbutton ACCESSKEY='A'>"+html_img(add_img)+"</button>";
  html+="</TD>";  
  html+="<TH align=center>"+GetNextVersionNumber()+"</TH>";
  html+="<TD align=center><input type=text name=clslab size=8 class='RALIGN' value='V"+GetNextVersionNumber()+"'></TD>";
  html+="<TD align=center><input type=text name=clsapp   class='APPNUM' value='"+lastapp+"' onchange='MOD_DOSSIER.onchangeappnum(this);'></TD>";
  html+="<TD align=center><input type=text name=clsdate  class='DATE' value='"+lastdate+"' onchange='MOD_DOSSIER.onchangedate(this)'></TD>";
  html+="<TD align=center>"+html_selection("clsphase",PHASES,lastphase)+"</TD>";
  html+="<TD align=center><input type=text name=clsnum size=8  value=1 class='RALIGN'></TD>";   
  html+="<TD align=center>";
  html+="<BUTTON onclick='add_claimset(clsdate.value,html_selected(\"clsphase\",PHASES),clsapp.value,clsnum.value,clslab.value);'";
  html+=" id=addcsbutton ACCESSKEY='A'>"+html_img(add_img)+"</button>";
  html+="</TD>";  
  html+="</TR>";  
  html+="</TABLE>";

  return html;
}

//
// Edit 
//



function show_editdossier(editvers) { 
  var vers;
  if(!DOSSIER) {
    alert("Create or Load a dossier first !");
    return;
  }
  if(editvers) {
    MOD_DOSSIER.editvers=editvers;
  }
  if(!MOD_DOSSIER.editvers) {
    MOD_DOSSIER.editvers=0;
  }
  
  if(!GetDossierTitle() || !GetDossierKeywords()) {
    MOD_DOSSIER.defdata=CaesarImportDossier(GetDossierNumber(),finddefaultappnum());
  }
  
  var html="<H3><BUTTON TYPE=Button onclick='save_dossier();' ACCESSKEY='S' >"+html_img(section_img)+"</BUTTON> Edit Dossier</H3>";

  html+="<TABLE><TH align=left colspan=2>";
  html+="<fieldset style='width:10%'><legend>Num.</legend>";
  html+="<input type=text size=4 class='RWTXT' align=right name=dosord value='"+GetDossierOrdNum()+"' onchange='MOD_DOSSIER.changedosordnum(this);'>";
  html+="</fieldset> ";

  html+="<fieldset style='width:10%'><legend>Lang</legend>";
  html+=html_selection_iter("doslang",new lang_iterator(),GetDossierLang(),"MOD_DOSSIER.onchangedoslang()");
  html+="</fieldset> ";
  html+="<fieldset style='width:10%'><legend>Priority</legend>";
  html+="<input type=text name=dospri  class='DATE RWTXT' value='"+GetDossierPri()+"' onChange='MOD_DOSSIER.changedospri(this);'>";
  html+="</fieldset> ";

  html+="<fieldset style='width:10%'><legend>Applicant</legend>";
  html+="<input type=text size=61  class='RWTXT' name=dosapp  value='"+GetDossierApplicant()+"' onchange='SetDossierApplicant(this.value);'>";
  html+="</fieldset>";
  html+="<BR></TH></TR>";
  html+="<TR><TH align=left colspan=2>";
  html+="<fieldset style='width:10%'><legend>Title</legend><input type=text class='RWTXT' size=97 name=dostitle value='";
  html+=GetDossierTitle()+"' onchange='SetDossierTitle(this.value);'></fieldset></TH></TR>";
  
  html+="<TR><TH align=left colspan=2><fieldset style='width:10%'><legend>Keywords</legend>";
  html+=html_flexarea(GetDossierKeywords(),"SetDossierKeywords(html_flexarea_selected().value)","",60);
  html+="</fieldset></TH></TR>";
  html+="<TR><TH align=left> Description </TH><TH ALIGN=right><button onClick='MOD_DOSSIER.open_desc();'>"+html_img(magnp_img)+"</button>";
  html+="<button onClick='MOD_DOSSIER.do_importdesc();'>"+html_img(import_img)+"</button></TH></TR>";
  var minidesc=GetDossierDescription().substring(1,110);
  html+="<TR><TD colspan=2>"+html_flexarea(minidesc ? (minidesc+"..."):"","","id='minidesc' readonly",60)+"</TH></TR>";

  html+="<TR><TH align=left><br><h3>Claim Sets</h3></TH></TR>";
  html+="<TR><TD colspan=2>"+MOD_DOSSIER._editclaimsets(show_editdossier)+"</TD></TR>";
  html+="</TABLE>";

  html_display(html);

  ClaimToolTitle("short");

  if(!GetClaimSet()) {
    CT_hide_menu("Edit");
    CT_hide_menu("Comms");
    CT_show_menu("Tools");
  } else {
    CT_show_menu("Edit");
    CT_show_menu("Comms");
    CT_show_menu("Tools");
  }
}



